package cn.abyss.admin.ums.business;

import cn.abyss.admin.consts.AdminWebConstants;
import cn.abyss.admin.enums.AdminWebExceptionEnum;
import cn.abyss.admin.exception.AdminWebException;
import cn.abyss.admin.exception.BaseException;
import cn.abyss.admin.ums.model.UmsResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Description:
 *
 * @author zhangsj
 * @date Created on 2021/8/26
 */
@Component
public class UmsResourceBusiness {
    @Autowired
    private UmsAdminRoleRelationBusiness umsAdminRoleRelationBusiness;

    /**
     * 获取用户所有可访问资源
     */
    public List<UmsResource> getResourceList(Long adminId) {
        try {
            List<UmsResource> umsResources = umsAdminRoleRelationBusiness.getResourceList(adminId);
            return umsResources;
        } catch (BaseException bex) {
            throw bex;
        } catch (Exception e) {
            throw new AdminWebException(AdminWebConstants.UMS_ADMIN,
                    AdminWebExceptionEnum.ADMIN_WEB_RESOURCE_QUERY_BYNAME_FAIL, e);
        }
    }
}
